/**
 */
package moore.impl;

import moore.AbstractState;
import moore.Input;
import moore.MoorePackage;
import moore.conditionState;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>condition State</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link moore.impl.conditionStateImpl#getFalseOutputState <em>False Output State</em>}</li>
 *   <li>{@link moore.impl.conditionStateImpl#getInputSignal <em>Input Signal</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class conditionStateImpl extends AbstractStateImpl implements conditionState {
	/**
	 * The cached value of the '{@link #getFalseOutputState() <em>False Output State</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFalseOutputState()
	 * @generated
	 * @ordered
	 */
	protected AbstractState falseOutputState;

	/**
	 * The cached value of the '{@link #getInputSignal() <em>Input Signal</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInputSignal()
	 * @generated
	 * @ordered
	 */
	protected Input inputSignal;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected conditionStateImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MoorePackage.Literals.CONDITION_STATE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AbstractState getFalseOutputState() {
		if (falseOutputState != null && falseOutputState.eIsProxy()) {
			InternalEObject oldFalseOutputState = (InternalEObject)falseOutputState;
			falseOutputState = (AbstractState)eResolveProxy(oldFalseOutputState);
			if (falseOutputState != oldFalseOutputState) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE, oldFalseOutputState, falseOutputState));
			}
		}
		return falseOutputState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AbstractState basicGetFalseOutputState() {
		return falseOutputState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFalseOutputState(AbstractState newFalseOutputState) {
		AbstractState oldFalseOutputState = falseOutputState;
		falseOutputState = newFalseOutputState;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE, oldFalseOutputState, falseOutputState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Input getInputSignal() {
		if (inputSignal != null && inputSignal.eIsProxy()) {
			InternalEObject oldInputSignal = (InternalEObject)inputSignal;
			inputSignal = (Input)eResolveProxy(oldInputSignal);
			if (inputSignal != oldInputSignal) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MoorePackage.CONDITION_STATE__INPUT_SIGNAL, oldInputSignal, inputSignal));
			}
		}
		return inputSignal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Input basicGetInputSignal() {
		return inputSignal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetInputSignal(Input newInputSignal, NotificationChain msgs) {
		Input oldInputSignal = inputSignal;
		inputSignal = newInputSignal;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MoorePackage.CONDITION_STATE__INPUT_SIGNAL, oldInputSignal, newInputSignal);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInputSignal(Input newInputSignal) {
		if (newInputSignal != inputSignal) {
			NotificationChain msgs = null;
			if (inputSignal != null)
				msgs = ((InternalEObject)inputSignal).eInverseRemove(this, MoorePackage.INPUT__CHECKED_IN, Input.class, msgs);
			if (newInputSignal != null)
				msgs = ((InternalEObject)newInputSignal).eInverseAdd(this, MoorePackage.INPUT__CHECKED_IN, Input.class, msgs);
			msgs = basicSetInputSignal(newInputSignal, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MoorePackage.CONDITION_STATE__INPUT_SIGNAL, newInputSignal, newInputSignal));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				if (inputSignal != null)
					msgs = ((InternalEObject)inputSignal).eInverseRemove(this, MoorePackage.INPUT__CHECKED_IN, Input.class, msgs);
				return basicSetInputSignal((Input)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				return basicSetInputSignal(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE:
				if (resolve) return getFalseOutputState();
				return basicGetFalseOutputState();
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				if (resolve) return getInputSignal();
				return basicGetInputSignal();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE:
				setFalseOutputState((AbstractState)newValue);
				return;
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				setInputSignal((Input)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE:
				setFalseOutputState((AbstractState)null);
				return;
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				setInputSignal((Input)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MoorePackage.CONDITION_STATE__FALSE_OUTPUT_STATE:
				return falseOutputState != null;
			case MoorePackage.CONDITION_STATE__INPUT_SIGNAL:
				return inputSignal != null;
		}
		return super.eIsSet(featureID);
	}

} //conditionStateImpl
